package me.yushuai.wukong.base.entity;

import lombok.*;
import org.hibernate.Hibernate;
import org.hibernate.annotations.Type;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

/**
 * 装箱
 *
 * @author zhoushuai@189.cn
 * @since 2022-09-09
 */
@Getter
@Setter
@ToString
@Entity
@Table(name = "BAS_CARTON")
public class Carton implements Serializable {
    /**
     * 装箱编号
     */
    @Id
    @Column(name = "ID")
    private Long id;

    /**
     * 装箱编码
     */
    @Column(name = "BIZ_ID", updatable = false, nullable = false)
    private String bizId;

    /**
     * 仓库ID
     */
    @Column(name = "WAREHOUSE_ID", updatable = false, nullable = false)
    private Long warehouseId;

    /**
     * 装箱组
     */
    @Column(name = "CARTON_GROUP_ID", updatable = false, nullable = false)
    private Long cartonGroupId;

    /**
     * 中文描述
     */
    @Column(name = "DESC_CH")
    private String descCh;

    /**
     * 体积限制
     */
    @Column(name = "MAX_CUBIC")
    private BigDecimal maxCubic;

    /**
     * 重量限制
     */
    @Column(name = "MAX_WEIGHT")
    private BigDecimal maxWeight;

    /**
     * 数量限制
     */
    @Column(name = "MAX_COUNT")
    private BigDecimal maxCount;

    /**
     * 长
     */
    @Column(name = "LENGTH")
    private BigDecimal length;

    /**
     * 宽
     */
    @Column(name = "WIDTH")
    private BigDecimal width;

    /**
     * 高
     */
    @Column(name = "HEIGHT")
    private BigDecimal height;

    /**
     * 浮动容积上限
     */
    @Column(name = "CUBIC_UP_LIMIT")
    private BigDecimal cubicUpLimit;

    /**
     * 激活
     */
    @Type(type = "yes_no")
    @Column(name = "ACTIVE_FLAG")
    private Boolean activeFlag;


    /**
     * 默认标记
     */
    @Type(type = "yes_no")
    @Column(name = "DEFAULT_FLAG")
    private Boolean defaultFlag;

    /**
     * 计费重量
     */
    @Column(name = "BILLING_WEIGHT")
    private BigDecimal billingWeight;

    /**
     * 用户自定义1
     */
    @Column(name = "UDF1")
    private String udf1;

    /**
     * 用户自定义2
     */
    @Column(name = "UDF2")
    private String udf2;

    /**
     * 用户自定义3
     */
    @Column(name = "UDF3")
    private String udf3;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
            return false;
        }
        Carton carton = (Carton) o;
        return id != null && Objects.equals(id, carton.id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}